import _ from 'lodash';

export default {
  getDepartments(departments) {
    const departmentTree = [];
    _.forEach(departments, (item) => {
      const menu = {
        value: item.id,
        label: item.name,
      };
      if (item.children && item.children.length > 0) {
        menu.children = this.getDepartments(item.children);
      }
      departmentTree.push(menu);
    });
    return departmentTree;
  }
}
